<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>销售预测列表</title>
    <meta name="decorator" content="default"/>
    <link rel="stylesheet" href="${ctxStatic}/bootstrap-table/bootstrap-table.css">
    <script src="${ctxStatic}/bootstrap-table/bootstrap-table.js"></script>
    <script src="${ctxStatic}/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
    <script src="${ctxStatic}/bootstrap-table/config.js"></script>
</head>
<body>
    <form id="searchForm" action="${ctx}/customer/analyse/listData" method="post" class="breadcrumb form-search">
        <ul class="ul-form">
            <ul class="ul-form">
                <li>
                    <div class="input-prepend">
                        <span class="add-on">意向产品</span>
                        <sys:productType name="targetProducts" withWu="true" cssClass="select-medium" withAll="true"/>
                    </div>
                    <div class="input-prepend">
                        <span class="add-on">预计程度</span>
                        <select name="minPercentage" class="select-medium">
                            <option value="0">全部</option>
                            <option value="10">>=10%</option>
                            <option value="20">>=20%</option>
                            <option value="30">>=30%</option>
                            <option value="40">>=40%</option>
                            <option value="50">>=50%</option>
                            <option value="60">>=60%</option>
                            <option value="70">>=70%</option>
                            <option value="80">>=80%</option>
                            <option value="90">>=90%</option>
                            <option value="100">>=100%</option>
                        </select>
                    </div>

                </li>

                <li class="clearfix"></li>
            </ul>
            <ul class="ul-form">
                <li>
                    <div class="input-prepend">
                        <span class="add-on">开始时间</span>
                        <input readonly="true" name="beginDate" type="text" class="input-medium"
                               onmousedown="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                    </div>
                    <div class="input-prepend">
                        <span class="add-on">结束时间</span>
                        <input readonly="true" name="endDate" type="text" class="input-medium"
                               onmousedown="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                    </div>
                </li>
                <li class="btns">
                    <button id="search" class="btn btn-small btn-primary" type="button">
                        查询<span class="icon-search icon-white"></span>
                    </button>
                </li>
            </ul>
        </ul>
    </form>

	<table id="contentTable" data-url="${ctx}/customer/analyse/listData">
        <thead>
        <tr>
            <th data-align="center" data-formatter="indexFormat">序号</th>
            <th data-field="productType" data-align="center" data-formatter="productTypeFormat">意向产品</th>
            <th data-field="user" data-align="center" data-formatter="userFormat">跟进人</th>
            <th data-field="predictSaleDate"  data-align="center">预计成单日期</th>
            <th data-field="predictSaleAmount"  data-align="center">预期金额</th>
            <th data-field="predictSalePercentage"  data-align="center">可能性</th>
            <th data-align="center" data-formatter="statusFormat">回访状态</th>
            <th data-field="holdTime"  data-align="center">阶段停留时间</th>
            <th data-align="center" data-formatter="operateFormatter" data-events="operateEvents" >操作</th>
        </tr>
        </thead>
	</table>
    <script type="text/javascript">
        $(document).ready(function() {
            closeTip();
            $("#contentTable").bootstrapTable(
                $.fn.BTConfigSimple({
                    pageList: [30, 50, 100],
                    pageSize: 30,
                    sortName: "id"
                }));

            $("#search").click(function () {
                refresh();
            });
            $(".addTab").live("click", function () {
                return window.parent.addTab($(this));
            });
        });
        //全局函数部分
        function refresh(){
            $("#contentTable").bootstrapTable(
                'refresh',
                $("#searchForm").refreshByForm());
        }

        function indexFormat(v,r,i){
            return i + 1;
        }

        function productTypeFormat(v){
           return v?v.productTypeName:"-";
        }

        function userFormat(v){
            return v?v.name:"-";
        }

        function statusFormat(v,r){
            var s = r.customerStatus;
            var d = r.customerStatusDetail;
            return s?s.content + (d? ":"+d.causeDesc:""):"-";
        }
        function lastFormat(v){

        }

        function operateFormatter(value, row, index){
            var array = [];
            array.push('<a class="addTab" target="mainFrame" href="${ctx}/customer/potentialCustomer/detail?id='+row.potentialCustomerId+'" title="查看客户">');
            array.push(row.customerName);
            array.push('</a>');
            return array.join('');
        }

    </script>
</body>
</html>